<template>
  <el-dialog :title="title" :visible.sync="open" width="80%" append-to-body :close-on-click-modal="false"
             v-dialogDrag>
    <div class="app-container">

      <el-table border v-loading="loading" :data="dataList" ref="table"
                :max-height="tableMaxHeight">
        <!--<el-table-column label="出入库状态" align="center" prop="type">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.churuku_type" :value="scope.row.type"/>
          </template>
        </el-table-column>-->
        <el-table-column  align="center" label="工序编码" prop="code"/>
        <el-table-column  align="center" label="工序名称" prop="name"/>
        <el-table-column align="center" label="图纸号" prop="shuoming"/>
        <el-table-column align="center" label="工序图纸" prop="photo"/>
        <el-table-column align="center" label="工序文件" prop="file"/>
        <el-table-column align="center" label="产品数量" prop="counts"/>
        <el-table-column align="center" label="分配数量" prop="fenpeiCount"/>
        <el-table-column align="center" label="完成数量" prop="finishCount"/>
        <el-table-column align="center" label="备注" prop="remark"/>
        <el-table-column align="center" class-name="small-padding fixed-width" label="操作">
          <template slot-scope="scope">
            <el-button @click="feipeiPeople(scope.row)" icon="el-icon-view" size="mini" type="text">
              分配人员
            </el-button>
          </template>
        </el-table-column>
      </el-table>

      <feipeiPeopleForm-list @ok="getList" ref="feipeiPeopleForm"></feipeiPeopleForm-list>
      <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum"
                  :limit.sync="queryParams.pageSize" @pagination="getList"/>
    </div>
  </el-dialog>
</template>

<script>
  import {deleteAction, downloadFile, getAction, getById} from '@/api/manage'
  import FeipeiPeopleFormList from "@/views/develop/projectBaseInfo/prjForGoodsIn/FeipeiPeopleFormList";

  export default {
    name: "FpTaskFormList",
    dicts: ['churuku_type'],
    components: {
      FeipeiPeopleFormList
    },
    data() {
      return {
        title: "工艺工序",
        open: false,
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        rows: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 销售信息管理表格数据
        dataList: [],
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 20,
          saleId: null,
          goodsId: null,
          goodsName: null,
          goodsBrand: null,
          goodsUnitPrice: null,
          goodsCount: null,
          dateRange: "",
          params: {},
        },
        url: {
          listByGoodsId: '/goodsSaledoGongxu/goodsSaledoGongxu/list',
        },
        PrjNameOptions: [],
        tableMaxHeight: window.innerHeight - 320,
      };
    },
    created() {
      window.addEventListener('resize', this.getTableHeight);
    },
    destroyed() {
      window.removeEventListener('resize', this.getTableHeight)
    },
    methods: {
      feipeiPeople(row){
        this.$refs.feipeiPeopleForm.feipeiPeopleShow(row);
      },
      taskFpShow(row) {
        let that = this;
        that.queryParams.saleId = row.id;
        that.getList();
        that.open = true;
      },
      getTableHeight() {
        this.tableHeight = window.innerHeight - 320
      },
      /** 查询销售信息管理列表 */
      getList() {
        this.loading = true;
        getAction(this.url.listByGoodsId, this.queryParams).then(response => {
          this.dataList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
    }
  };
</script>
